-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Gradient Accumulation fix across all models + trainer fully in forward() #34283
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I don't see Llama being modified, that's probably because it now has FlashAttentionKwargs
type dict as kwargs. We can create ExtraKwargs, a nested dict with both flash kwargs and loss kwargs and default loss kwargs can be type dict?
🤗
@ArthurZucker |
@@ -3610,8 +3612,11 @@ def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=N | |||
labels = inputs.pop("labels") | |||
else: | |||
labels = None | |||
# if num_items_in_batch is not None: | |||
# inputs["num_items_in_batch"] = num_items_in_batch | |||
if self.model_accepts_loss_kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if condition doesn't seem to work for PeftModel
class (it only has kwargs
not loss_kwargs
🫠 )
I tried just changing that condition to if True
and ran some tests, and the loss calculation worked perfectly for a LORA on a Llama 3 1B.
I'm wondering if there's a safe/non-breaking way to support peft models here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the flag, that may be why I couldn't recreate #34263 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@man-shar can you try giving peft another go? Should have fixed it
Awesome work by all of you on this. Insane dev speed over the past few days 🙏 🔥 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only reviewed the PEFT-related code in trainer.py
and it LGTM. Thanks Zach.
What does this PR do?
Since most users still want OOTB, this trickles the loss kwargs to the rest of the models so that causal loss can be calculated properly
Fixes # (issue)
Fully fixes #34263 / finishes #34191 & #34198
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@ArthurZucker